<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>随机点名</title>
</head>
<body>
	<script type="text/javascript">
		// 方法一
		// var strName = ['张三','李四','王五','赵六'];
		// function randName( arr ){
		// 	var randNum =  Math.floor(Math.random()*(arr.length+1)-1);
		// 	if( randNum > (arr.length-1) || randNum < 0){
		// 		var randNum =  Math.floor(Math.random()*(arr.length+1)-1);
		// 	}
		// 	return arr[randNum];
		// }
		// document.write(randName(strName));
		// 方法二
		var strName = ['张三','李四','王五','赵六'];
		function randName( arr ){
			var randMin = 0;
			var randMax = arr.length - 1;
			var randNum = Math.random()*(randMax);
			return arr[Math.round(randNum)];
		}
		document.write(randName(strName));
	</script>
</body>
</html>